package com.tanhua.server.controller;

import com.tanhua.model.vo.UserInfoVo;
import com.tanhua.server.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * 用户管理控制层
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserInfoService userInfoService;

    /**
     *  首次登录---完善资料
     *  @RequestHeader("Authorization"):获取请求头中token
     *  UserInfoVo:vo 接收或响应app数据对象
     */
    @RequestMapping(value = "/loginReginfo",method = RequestMethod.POST)
    public ResponseEntity loginReginfo(@RequestBody UserInfoVo userInfoVo){
        userInfoService.loginReginfo(userInfoVo);
        return ResponseEntity.ok(null);
    }


    /**
     * 头像上传
     * 方式一：MultipartFile  headPhoto
     * 方式二：@RequestParam("headPhoto") MultipartFile xxxx
     * @param  headPhoto
     * @return
     */
    @RequestMapping(value = "/loginReginfo/head",method = RequestMethod.POST)
    public ResponseEntity loginReginfoHead(MultipartFile headPhoto){
        userInfoService.loginReginfoHead(headPhoto);
        return ResponseEntity.ok(null);
    }

}
